import 'package:flutter/material.dart';

class CheckboxDemo extends StatefulWidget {
  CheckboxDemo({Key key}) : super(key: key);

  _CheckboxDemoState createState() => _CheckboxDemoState();
}

class _CheckboxDemoState extends State<CheckboxDemo> {
  bool _selectitema1 = true;
  bool _selectitema2 = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('CheckboxDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            // 复选框 list 碎片
            CheckboxListTile(
              value: _selectitema1,
              title: Text('checkbox item A'),
              subtitle: Text('Descriptions'),
              secondary: Icon(Icons.bookmark),
              activeColor: Colors.red,
              selected: _selectitema1,
              onChanged: (v) {
                setState(() {
                  _selectitema1 = v;
                });
                print('onChanged :_selectitema1 == $v');
              },
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Checkbox(
                  value: _selectitema2,
                  activeColor: Colors.black,
                  checkColor: Colors.red,

                  // inactiveColor
                  onChanged: (v) {
                    setState(() {
                      _selectitema2 = v;
                    });
                    print('onChanged :_selectitema2 == $v');
                  },
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
